# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Tor Krill <tor@krill.nu>
# Contributor: Lee.MaRS <leemars@gmail.com>

pkgname=gsoap
pkgver=2.8.127
pkgrel=1
pkgdesc="Offers an XML language binding to ease the development of SOAP/XML Web services in C and C/C++"
url="https://www.cs.fsu.edu/~engelen/soap.html"
arch=('loong64' 'x86_64')
license=('GPL' 'custom')
depends=('openssl' 'zlib' 'gcc-libs')
makedepends=('autoconf' 'automake')
options=('staticlibs')
source=("https://prdownloads.sourceforge.net/gsoap2/${pkgname}_${pkgver}.zip")
sha256sums=('25ecad1bbc363494eb7ea95a68508e4c93cc20596fad9ebc196c6572bbbd3c08')

prepare() {
  cd "$srcdir"/gsoap-2.8
#  sed -i 's/#  if !defined(_GNU_SOURCE) ||/#  if !defined(_GNU_SOURCE) \&\&/' gsoap/stdsoap2.{c,cpp}
}

build() {
  cd "$srcdir"/gsoap-2.8
  # needed for programs which use gsoap and have -fPIC enabled
  # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=353724
  export CFLAGS="$CFLAGS -fPIC -ffat-lto-objects"
  export CXXFLAGS="$CXXFLAGS -fPIC -ffat-lto-objects"
  ./configure --prefix=/usr
  make
}

package() {
  cd "$srcdir"/gsoap-2.8
  make DESTDIR="$pkgdir" install
  mkdir -p "$pkgdir"/usr/share/gsoap/import
  mkdir -p "$pkgdir"/usr/share/gsoap/WS
  cp -R gsoap/import "$pkgdir"/usr/share/gsoap/
  cp -R gsoap/WS "$pkgdir"/usr/share/gsoap/
  install -D LICENSE.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.txt
}
